package org.nanotek.mq.message;

import java.util.Date;

import org.nanotek.StringKong;
import org.nanotek.cms.domain.message.BodyMessageContainer;
import org.nanotek.cms.domain.message.MessageType;
import org.nanotek.mq.MessageBuilder;
import org.nanotek.Base;
import org.nanotek.util.StringKongBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseMessageBuilder<Message, I,S extends StringKong> implements MessageBuilder<Message, I, StringKong> {

	public BaseMessageBuilder() {}
    @Autowired StringKongBuilder stringKongBuilder;


	private Long getId() {
		return new Date().getTime();
	}

	@Override
	public StringKong newHeader() {
		return new StringKong(Long.toString(System.currentTimeMillis()));
	}

	@Override
	public StringKong newHeader(StringKong sourceMessage) {
		return  stringKongBuilder.buildKongString(sourceMessage);
	}

	//A free parameter for future use, since was created... let it.
	@Override
	public StringKong newHeader(StringKong sourceMessage, I info) {
		return  stringKongBuilder.buildKongString(sourceMessage);
	}

	@Override
	public Message newMessage() {
		return null;
	}

	@Override
	public Message newMessage(StringKong sourceMessage) {
		return null;
	}

	@Override
	public Message newMessage(StringKong sourceMessage, I info) {
		return null;
	}

	@Override
	public Message newMessage(StringKong header, StringKong sourceMessage,
			I info) {
		return null;
	}

	public BodyMessageContainer buildMessage(final MessageType msgType , final Base<?> message) {
		BodyMessageContainer messageContainer = new BodyMessageContainer();
		messageContainer.setId(getId());
//		messageContainer.setBodyMessage(message);
		messageContainer.setContainerAlias(message.getClass().getSimpleName());
		messageContainer.setMessageType(msgType);
		return messageContainer;
	}
}
